package com.pureut.quality.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.quality.domain.dto.AuditNonconformityDto;
import com.pureut.quality.domain.dto.MeetingRecordDto;
import com.pureut.quality.domain.vo.AuditNonconformityVo;
import com.pureut.quality.domain.vo.MeetingRecordVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.service.AuditNonconformityService;
import com.pureut.quality.service.MeetingRecordService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @ClassDescription: 会议纪要
 * @Author: YSL
 * @Created: 2025/4/8 10:19
 */
@RestController
@RequestMapping("/meetingRecord")
public class MeetingRecordController extends BaseController {

    /**
     * 会议纪要实现层
     */
    @Resource
    MeetingRecordService meetingRecordService;

    /**
     * 会议纪要列表
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:list")
    @GetMapping("/list")
    public TableDataInfo list(MeetingRecordVo meetingRecordVo)
    {
        startPage();
        List<MeetingRecordDto> list = meetingRecordService.listMeetingRecord(meetingRecordVo);
        return getDataTable(list);
    }

    /**
     * 根据id获取详细信息
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return AjaxResult.success(meetingRecordService.getInfo(id));
    }

    /**
     * 会议纪要新增
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "会议纪要新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody MeetingRecordVo meetingRecordVo) throws Exception {
        return toAjax(meetingRecordService.insertMeetingRecord(meetingRecordVo));
    }

    /**
     * 会议纪要修改
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "会议纪要修改", businessType = BusinessType.INSERT)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody MeetingRecordVo meetingRecordVo) throws Exception {
        return toAjax(meetingRecordService.updateMeetingRecord(meetingRecordVo));
    }

    /**
     * 会议纪要删除
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:remove")
    @Log(title = "会议纪要删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable("ids") String ids){
        return toAjax(meetingRecordService.removeMeetingRecord(ids));
    }

    /**
     * 导出
     */
    @PostMapping("/export")
//    @RequiresPermissions("warehouse:inside:inventoryCount:close")
    public AjaxResult inspectionMessageExport(HttpServletResponse response, MeetingRecordVo meetingRecordVo) throws IOException {
//        meetingRecordService.getInfoExport(meetingRecordVo);
//        ExcelUtil<CheckManagementExport> excelUtil = new ExcelUtil<CheckManagementExport>(CheckManagementExport.class);
//        excelUtil.excelWriter(response, infoExport, "盘点单信息.xlsx");
        return AjaxResult.success();
    }

}
